﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace MixScript.BLL.FI
{
    public class cSubGroup : cBaseBLL
    {


        public cSubGroup() { }
        public bool getSubGroupCOA(ref DataTable dt, int SubGroupid)
        {
            try
            {
                dt = new DataTable();
                string sSQL = @"SELECT * FROM accsubgroup s
                            where s.subnum  = {0}";
                dt = Dbserver.ExecuteQuery(string.Format(sSQL, SubGroupid), "vw_coamst");
                return dt.Rows.Count > 0;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        public bool saveGroup(Int32 GroupID, string name, string acc, bool isNew)
        {
            string sql;
            if (isNew)
                sql = "INSERT INTO accgroup (groupnum,groupname,aplication) VALUES ('{0}','{1}','{2}')";
            else
                sql = "UPDATE accgroup SET groupname='{1}',aplication='{2}' WHERE groupnum = {0}";
            try
            {
                Dbserver.ExecuteScalar(String.Format(sql, GroupID, name, acc));
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }


        }
    }
}
